import tkinter as tk
from tkinter import filedialog, messagebox
import pandas as pd

file_path = None

def choose_file():
    global file_path
    file_path = filedialog.askopenfilename(filetypes=[("Excel files", "*.xlsx")])
    if file_path:
        selected_file_label.config(text="已选择文件：" + file_path)

def execute_code():
    global file_path
    if not file_path:
        messagebox.showwarning("警告", "请先选择文件")
        return



    # 这里可以调用你之前提供的代码进行处理
    print('测试，我是测试')
    print('测试，我是测试')
    print('测试，我是测试')



root = tk.Tk()
root.title('办公自动化')
root.geometry('800x300+200+200')


    # 放置按钮的Frame
button_frame = tk.Frame(root)
button_frame.pack(pady=10)

    # 选择文件按钮
choose_file_button = tk.Button(button_frame, text="选择文件", command=choose_file)
choose_file_button.pack(side=tk.LEFT, padx=10)

    # 执行代码按钮
execute_code_button = tk.Button(button_frame, text="执行代码", command=execute_code)
execute_code_button.pack(side=tk.LEFT, padx=10)

    # 显示选择的文件路径
selected_file_label = tk.Label(root, text="未选择文件")
selected_file_label.pack(pady=10)

root.mainloop()
